package cn.edu.zju.om.crawler;


import java.io.File;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TaskManagerTests {

	@Before
	public void setUp() throws Exception {
		File dbDir = new File("taskDB");
		if (!dbDir.exists()) {
			return;
		}
		File[] files = dbDir.listFiles();
		for(File file : files) {
			file.delete();
		}
		dbDir.delete();
	}

	@After
	public void tearDown() throws Exception {
		TaskManager.getInstance().close();
		setUp();
	}
	
	@Test
	public void testAccuracy() {
		TaskManager.getInstance().addTask("abc.com");
		Assert.assertTrue(TaskManager.getInstance().hasTask());
		
		TaskManager.getInstance().getTask();
		
		TaskManager.getInstance().addTask("abc.com");
		Assert.assertFalse(TaskManager.getInstance().hasTask());
	}
}
